<?php 
$user=$_GET['username'];
$passwd=$_GET['password'];
// echo $user;
$conn=mysql_connect('localhost:3306','root','root');
mysql_select_db('user_data',$conn);
    //查询表中数据
$result=mysql_query("SELECT password,user FROM data WHERE user='".$user."'");
if(mysql_num_rows($result)){
	while($row=mysql_fetch_assoc($result)){
	    if($row['password']==$passwd && $row['user']==$user){
	        echo json_encode(array('status'=>'success','msg'=>'登陆成功'));
	    }else{
	        echo json_encode(array('status'=>'error','msg'=>'登录失败'));
	    }
	}
}else{
	 echo json_encode(array('status'=>'error','msg'=>'登录失败'));
}

mysql_close($conn);